﻿using System;
using System.Collections.Generic;

namespace DiIoc.Signal.ObserverPattern
{
    public class Subject
    {
        public List<Observer> Observers = new List<Observer>();

        private string _state;

        public string State {
            get
            {
                return _state;
            }
            set
            {
                _state = value;
                NotifyAllObservers();
            }
        }
        public void AttachObserver(Observer observer)
        {
            Observers.Add(observer);
        }
        private void NotifyAllObservers()
        {
            foreach (var item in Observers)
            {
                item.Update();
            }
        }
    }
}